import 'package:ati_package/core/extension/ati_widgets_extension.dart';
import 'package:ati_package/core/routes/app_routes.dart';
import 'package:ati_package/pages/common/ati_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class NewsView extends StatefulWidget {
  const NewsView({super.key});

  @override
  State<NewsView> createState() => _NewsViewState();
}

class _NewsViewState extends State<NewsView> {
  @override
  Widget build(BuildContext context) {
    return AtiScaffold(title: '新闻资讯', body: buildNewsListWidget());
  }

  buildNewsListWidget() {
    return ListView.builder(
      itemCount: 15,
      itemBuilder: (context, index) {
        return Container(
          margin: EdgeInsets.symmetric(vertical: 6.r, horizontal: 15.r),
          padding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 15.r),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(12.r),
          ),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              // 左边文字
              Expanded(
                child: Container(
                  padding: EdgeInsetsGeometry.symmetric(vertical: 3.r),
                  height: 64.r,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        'ATI 沙棘 NFC 原浆赋能报单计划结束通知',
                        style: TextStyle(
                          fontSize: 14.sp,
                          fontWeight: FontWeight.w600,
                        ),
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                      ),
                      Text(
                        '2025-09-25 00:00:00',
                        style: TextStyle(fontSize: 11.sp, color: Colors.grey),
                      ),
                    ],
                  ),
                ),
              ),
              SizedBox(width: 10.w),
              Image.asset(
                width: 64.r,
                height: 64.r,
                'assets/images/find/news_list_m.png',
                package: 'ati_package',
              ),
            ],
          ),
        ).addTapGesture(
          onTap: () {
            Get.toNamed(AtiAppRoutes.newsDet);
          },
        );
      },
    );
  }
}
